import { createRouter, createWebHashHistory } from 'vue-router'

import NProgress from 'nprogress'
import 'nprogress/nprogress.css'



import Layout from '@/layout'

/**
 * 路由元信息meta参数说明
 * hide : 是否隐藏
 * title : 导航的标题
 * icon : 导航的icon图标类名
 */

const routes = [
  {
    path: '/',
    name: 'index',
    component: () => import('../views/Index'),
    meta: { hide: true },
  },
  {
    path: '/index',
    name: 'home',
    component: () => import('../views/Home'),
    meta: { title: '首页', hide: false, icon: 'el-icon-house', id: '1' },
  },
  {
    path: '/setting',
    name: 'setting',
    component: Layout,
    meta: { title: '系统管理', hide: false, icon: 'el-icon-location', id: '2' },
    children: [
      {
        path: '',
        name: 'easysetting',
        component: () => import('../views/Setting'),
        meta: { title: '基础管理', hide: false, icon: 'el-icon-location', id: '3' },
      },
    ],
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: routes,
})


router.beforeEach((to, from, next) => {
  NProgress.start()
  next()
})

router.afterEach(() => {
  NProgress.done()
})
export default router
export { routes }
